<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Price My House: qmlapplicationviewer.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="PriceMyHouse.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Price My House&#160;<span id="projectnumber">Alpha 1</span></div>
   <div id="projectbrief">Application documentation, Nokia mobile version</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00006.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">qmlapplicationviewer.cpp</div>  </div>
</div>
<div class="contents">
<a href="a00006.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// checksum 0x17fa version 0x3000a</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment">  This file was generated by the Qt Quick Application wizard of Qt Creator.</span>
<a name="l00004"></a>00004 <span class="comment">  QmlApplicationViewer is a convenience class containing mobile device specific</span>
<a name="l00005"></a>00005 <span class="comment">  code such as screen orientation handling. Also QML paths and debugging are</span>
<a name="l00006"></a>00006 <span class="comment">  handled here.</span>
<a name="l00007"></a>00007 <span class="comment">  It is recommended not to modify this file, since newer versions of Qt Creator</span>
<a name="l00008"></a>00008 <span class="comment">  may offer an updated version of it.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="a00007.html">qmlapplicationviewer.h</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;QtCore/QCoreApplication&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;QtCore/QDir&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;QtCore/QFileInfo&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;QtDeclarative/QDeclarativeComponent&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;QtDeclarative/QDeclarativeEngine&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;QtDeclarative/QDeclarativeContext&gt;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#if defined(QMLJSDEBUGGER)</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#include &lt;qt_private/qdeclarativedebughelper_p.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#endif</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#if defined(QMLJSDEBUGGER) &amp;&amp; !defined(NO_JSDEBUGGER)</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#include &lt;jsdebuggeragent.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#endif</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#if defined(QMLJSDEBUGGER) &amp;&amp; !defined(NO_QMLOBSERVER)</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#include &lt;qdeclarativeviewobserver.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#endif</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#if defined(QMLJSDEBUGGER)</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="comment">// Enable debugging before any QDeclarativeEngine is created</span>
<a name="l00034"></a>00034 <span class="keyword">struct </span>QmlJsDebuggingEnabler
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036     QmlJsDebuggingEnabler()
<a name="l00037"></a>00037     {
<a name="l00038"></a>00038         QDeclarativeDebugHelper::enableDebugging();
<a name="l00039"></a>00039     }
<a name="l00040"></a>00040 };
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="comment">// Execute code in constructor before first QDeclarativeEngine is instantiated</span>
<a name="l00043"></a>00043 <span class="keyword">static</span> QmlJsDebuggingEnabler enableDebuggingHelper;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="preprocessor">#endif // QMLJSDEBUGGER</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a><a class="code" href="a00003.html">00047</a> <span class="keyword">class </span><a class="code" href="a00003.html">QmlApplicationViewerPrivate</a>
<a name="l00048"></a>00048 {
<a name="l00049"></a><a class="code" href="a00003.html#a1f47874ad0a78ab9c06b78662b31225f">00049</a>     QString <a class="code" href="a00003.html#a1f47874ad0a78ab9c06b78662b31225f">mainQmlFile</a>;
<a name="l00050"></a><a class="code" href="a00003.html#a7f82e38d9994cdd669ba61d3c5a76ccf">00050</a>     <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00002.html">QmlApplicationViewer</a>;
<a name="l00051"></a>00051     <span class="keyword">static</span> QString <a class="code" href="a00003.html#ab7e84df22ca70fddfb6cea36d0a2dc97">adjustPath</a>(<span class="keyword">const</span> QString &amp;path);
<a name="l00052"></a>00052 };
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="a00003.html#ab7e84df22ca70fddfb6cea36d0a2dc97">00054</a> QString <a class="code" href="a00003.html#ab7e84df22ca70fddfb6cea36d0a2dc97">QmlApplicationViewerPrivate::adjustPath</a>(<span class="keyword">const</span> QString &amp;path)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056 <span class="preprocessor">#ifdef Q_OS_UNIX</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span><span class="preprocessor">#ifdef Q_OS_MAC</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (!QDir::isAbsolutePath(path))
<a name="l00059"></a>00059         <span class="keywordflow">return</span> QCoreApplication::applicationDirPath()
<a name="l00060"></a>00060                 + QLatin1String(<span class="stringliteral">&quot;/../Resources/&quot;</span>) + path;
<a name="l00061"></a>00061 <span class="preprocessor">#else</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>    <span class="keyword">const</span> QString pathInShareDir = QCoreApplication::applicationDirPath()
<a name="l00063"></a>00063         + QLatin1String(<span class="stringliteral">&quot;/../share/&quot;</span>)
<a name="l00064"></a>00064         + QFileInfo(QCoreApplication::applicationFilePath()).fileName()
<a name="l00065"></a>00065         + QLatin1Char(<span class="charliteral">&#39;/&#39;</span>) + path;
<a name="l00066"></a>00066     <span class="keywordflow">if</span> (QFileInfo(pathInShareDir).exists())
<a name="l00067"></a>00067         <span class="keywordflow">return</span> pathInShareDir;
<a name="l00068"></a>00068 <span class="preprocessor">#endif</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span>    <span class="keywordflow">return</span> path;
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a><a class="code" href="a00002.html#a842902bbd62c77167410fd7676a8227c">00073</a> <a class="code" href="a00002.html#a842902bbd62c77167410fd7676a8227c">QmlApplicationViewer::QmlApplicationViewer</a>(QWidget *parent) :
<a name="l00074"></a>00074     <a class="code" href="a00001.html">QDeclarativeView</a>(parent),
<a name="l00075"></a>00075     <a class="code" href="a00002.html#a0c364690785d1bfa54d93b6bd54d841c">m_d</a>(new <a class="code" href="a00003.html">QmlApplicationViewerPrivate</a>)
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077     connect(engine(), SIGNAL(quit()), SLOT(close()));
<a name="l00078"></a>00078     setResizeMode(QDeclarativeView::SizeRootObjectToView);
<a name="l00079"></a>00079 <span class="preprocessor">#if defined(QMLJSDEBUGGER) &amp;&amp; !defined(NO_JSDEBUGGER)</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span>    <span class="keyword">new</span> QmlJSDebugger::JSDebuggerAgent(engine());
<a name="l00081"></a>00081 <span class="preprocessor">#endif</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#if defined(QMLJSDEBUGGER) &amp;&amp; !defined(NO_QMLOBSERVER)</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>    <span class="keyword">new</span> QmlJSDebugger::QDeclarativeViewObserver(<span class="keyword">this</span>, parent);
<a name="l00084"></a>00084 <span class="preprocessor">#endif</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>}
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="a00002.html#ae712368928844f50f7d6ebe6481595e4">00087</a> <a class="code" href="a00002.html#ae712368928844f50f7d6ebe6481595e4">QmlApplicationViewer::~QmlApplicationViewer</a>()
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089     <span class="keyword">delete</span> <a class="code" href="a00002.html#a0c364690785d1bfa54d93b6bd54d841c">m_d</a>;
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 
<a name="l00092"></a><a class="code" href="a00002.html#a41240898c2e371e987fad66304f0acaf">00092</a> <span class="keywordtype">void</span> <a class="code" href="a00002.html#a41240898c2e371e987fad66304f0acaf">QmlApplicationViewer::setMainQmlFile</a>(<span class="keyword">const</span> QString &amp;file)
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094     <a class="code" href="a00002.html#a0c364690785d1bfa54d93b6bd54d841c">m_d</a>-&gt;<a class="code" href="a00003.html#a1f47874ad0a78ab9c06b78662b31225f">mainQmlFile</a> = <a class="code" href="a00003.html#ab7e84df22ca70fddfb6cea36d0a2dc97">QmlApplicationViewerPrivate::adjustPath</a>(file);
<a name="l00095"></a>00095     setSource(QUrl::fromLocalFile(<a class="code" href="a00002.html#a0c364690785d1bfa54d93b6bd54d841c">m_d</a>-&gt;<a class="code" href="a00003.html#a1f47874ad0a78ab9c06b78662b31225f">mainQmlFile</a>));
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="a00002.html#ae288e38be0964d47a08382056fe940c8">00098</a> <span class="keywordtype">void</span> <a class="code" href="a00002.html#ae288e38be0964d47a08382056fe940c8">QmlApplicationViewer::addImportPath</a>(<span class="keyword">const</span> QString &amp;path)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100     engine()-&gt;addImportPath(<a class="code" href="a00003.html#ab7e84df22ca70fddfb6cea36d0a2dc97">QmlApplicationViewerPrivate::adjustPath</a>(path));
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00103"></a><a class="code" href="a00002.html#a80f58eb6d6210437a5e788155a865169">00103</a> <span class="keywordtype">void</span> <a class="code" href="a00002.html#a80f58eb6d6210437a5e788155a865169">QmlApplicationViewer::setOrientation</a>(<a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0b">ScreenOrientation</a> orientation)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105 <span class="preprocessor">#if defined(Q_OS_SYMBIAN)</span>
<a name="l00106"></a>00106 <span class="preprocessor"></span>    <span class="comment">// If the version of Qt on the device is &lt; 4.7.2, that attribute won&#39;t work</span>
<a name="l00107"></a>00107     <span class="keywordflow">if</span> (orientation != <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0ba43562095f1495c509eba50009e4fa8f0">ScreenOrientationAuto</a>) {
<a name="l00108"></a>00108         <span class="keyword">const</span> QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char(<span class="charliteral">&#39;.&#39;</span>));
<a name="l00109"></a>00109         <span class="keywordflow">if</span> (v.count() == 3 &amp;&amp; (v.at(0).toInt() &lt;&lt; 16 | v.at(1).toInt() &lt;&lt; 8 | v.at(2).toInt()) &lt; 0x040702) {
<a name="l00110"></a>00110             qWarning(<span class="stringliteral">&quot;Screen orientation locking only supported with Qt 4.7.2 and above&quot;</span>);
<a name="l00111"></a>00111             <span class="keywordflow">return</span>;
<a name="l00112"></a>00112         }
<a name="l00113"></a>00113     }
<a name="l00114"></a>00114 <span class="preprocessor">#endif // Q_OS_SYMBIAN</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00116"></a>00116     Qt::WidgetAttribute attribute;
<a name="l00117"></a>00117     <span class="keywordflow">switch</span> (orientation) {
<a name="l00118"></a>00118 <span class="preprocessor">#if QT_VERSION &lt; 0x040702</span>
<a name="l00119"></a>00119 <span class="preprocessor"></span>    <span class="comment">// Qt &lt; 4.7.2 does not yet have the Qt::WA_*Orientation attributes</span>
<a name="l00120"></a>00120     <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0baa2654139c60cbef50d0a8c21203b10f0">ScreenOrientationLockPortrait</a>:
<a name="l00121"></a>00121         attribute = <span class="keyword">static_cast&lt;</span>Qt::WidgetAttribute<span class="keyword">&gt;</span>(128);
<a name="l00122"></a>00122         <span class="keywordflow">break</span>;
<a name="l00123"></a>00123     <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0ba7fb4a2bba3f8cd44a3fdd176a9409707">ScreenOrientationLockLandscape</a>:
<a name="l00124"></a>00124         attribute = <span class="keyword">static_cast&lt;</span>Qt::WidgetAttribute<span class="keyword">&gt;</span>(129);
<a name="l00125"></a>00125         <span class="keywordflow">break</span>;
<a name="l00126"></a>00126     <span class="keywordflow">default</span>:
<a name="l00127"></a>00127     <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0ba43562095f1495c509eba50009e4fa8f0">ScreenOrientationAuto</a>:
<a name="l00128"></a>00128         attribute = <span class="keyword">static_cast&lt;</span>Qt::WidgetAttribute<span class="keyword">&gt;</span>(130);
<a name="l00129"></a>00129         <span class="keywordflow">break</span>;
<a name="l00130"></a>00130 <span class="preprocessor">#else // QT_VERSION &lt; 0x040702</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span>    <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0baa2654139c60cbef50d0a8c21203b10f0">ScreenOrientationLockPortrait</a>:
<a name="l00132"></a>00132         attribute = Qt::WA_LockPortraitOrientation;
<a name="l00133"></a>00133         <span class="keywordflow">break</span>;
<a name="l00134"></a>00134     <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0ba7fb4a2bba3f8cd44a3fdd176a9409707">ScreenOrientationLockLandscape</a>:
<a name="l00135"></a>00135         attribute = Qt::WA_LockLandscapeOrientation;
<a name="l00136"></a>00136         <span class="keywordflow">break</span>;
<a name="l00137"></a>00137     <span class="keywordflow">default</span>:
<a name="l00138"></a>00138     <span class="keywordflow">case</span> <a class="code" href="a00002.html#ac7c7e3771e785af566efd57ef319ac0ba43562095f1495c509eba50009e4fa8f0">ScreenOrientationAuto</a>:
<a name="l00139"></a>00139         attribute = Qt::WA_AutoOrientation;
<a name="l00140"></a>00140         <span class="keywordflow">break</span>;
<a name="l00141"></a>00141 <span class="preprocessor">#endif // QT_VERSION &lt; 0x040702</span>
<a name="l00142"></a>00142 <span class="preprocessor"></span>    };
<a name="l00143"></a>00143     setAttribute(attribute, <span class="keyword">true</span>);
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a><a class="code" href="a00002.html#ad899dc23f1a2c01276ec428db92215b8">00146</a> <span class="keywordtype">void</span> <a class="code" href="a00002.html#ad899dc23f1a2c01276ec428db92215b8">QmlApplicationViewer::showExpanded</a>()
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148 <span class="preprocessor">#ifdef Q_OS_SYMBIAN</span>
<a name="l00149"></a>00149 <span class="preprocessor"></span>    showFullScreen();
<a name="l00150"></a>00150 <span class="preprocessor">#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)</span>
<a name="l00151"></a>00151 <span class="preprocessor"></span>    showMaximized();
<a name="l00152"></a>00152 <span class="preprocessor">#else</span>
<a name="l00153"></a>00153 <span class="preprocessor"></span>    show();
<a name="l00154"></a>00154 <span class="preprocessor">#endif</span>
<a name="l00155"></a>00155 <span class="preprocessor"></span>}
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00006.html">qmlapplicationviewer.cpp</a>      </li>
      <li class="footer">Generated on Sun May 1 2011 15:04:04 for Price My House by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>
